<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js0201</title>
</head>
<body>
<script>
    var d = new Date(); //此处使用了js内置对象 Date (日期对象)
    var h = d.getHours();
    //if(h>=18) document.write("晚上好");
    //if(h>=23) document.write("夜深了，注意身体.");
    if(h>=8 && h<11){
        document.write("上午好");
    }else if(h>=12 && h<13){
        document.write("中午好");
    }else if(h>=14 && h<17){
        document.write("下午好");
        //document.bgColor = 'blue';
        document.body.style.background = '#ff0';
        //相当于 <style> body{background:#ff0;}</style>
    }else if(h>=18){
        document.write("晚上好");
        document.bgColor = 'red';
    }

    //if()   ;
    //if(){}
    //if(){}else{}
    //if(){}else if(){}else if(){}else{}

</script>
</body>
</html>